﻿using ShortUrl.Web.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SQLiteData
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length < 2)
            {
                return;
            }

            ShortUrlModel m = ShortUrlModel.Create(ESP.Tool.SystemDefinition.SystemSetting.GetAppSettingValue("ShortBaseUrl"),textBox1.Text);

            textBox2.Text = m.ShortUrl;

            getData();
        }

        private void getData()
        {
            DataTable dt = ShortUrlModel.GetList();
            dataGridView1.DataSource = dt;
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            getData();

            label3.Text = System.Configuration.ConfigurationManager.ConnectionStrings["ShortUrlDB_SqLite"].ConnectionString;
        }
    }
}
